<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>注册团队</title>
		<link href="<%=path%>/common/css/rpms_right.css" rel="stylesheet" type="text/css" />
<%
String info = (String)request.getParameter("info");
String username = (String)request.getAttribute("userName");
if(username == null)
{
	username = "";
}
%>
<script type="text/javascript" src="js/check.js"></script>
<script type="text/javascript">
	function checkRegister(){
	   
        if(nameCheckNull()&&checkLoginPassword()&&checkPasswordSame())      

             return true;
        else 

            return false ;
	}
	function checkLoginPassword()
	{
		var pswd1 = document.getElementById('newpassword1');
		if(pswd1.value.length == 0)
		{
			document.getElementById('error3').innerHTML = "密码不能为空";
			return false;
		}
		else 
			return true;
	}
    function checkPasswordSame(){
		var pswd1 = document.getElementById('newpassword1');
		var pswd2 = document.getElementById('newpassword2');

        if(pswd1.value != pswd2.value){
    	document.getElementById('error2').innerHTML = "两次密码输入不一致！";
    	return false;
    	}else if(checkLoginPassword()==true){
        	document.getElementById('error2').innerHTML = "";
        	return true;}
    	else{return false;}
    }
    
	function nameCheckNull(){
		var user = document.getElementById('_userName');
		var len = user.value.length;
		
	    if(len==0 || len<2 || len>8){
        document.getElementById('error1').innerHTML = "名字长度应在2—8个字符内  ";
        return false;
	    }else{
	    document.getElementById('error1').innerHTML = "";
	    return true;
	    }
	}

	function nameCheck(){
		var form = document.getElementById('nameCheckForm');
		var newname = document.getElementById('nameCheckName');
		var userName = document.getElementById('_userName');
		
		if(userName.value.length>0){
			newname.value = userName.value;
			form.submit();
		}
	}
</script>
</head>

	<body>
		<div class="main">
			<h1>
				注册学生用户
			</h1>
			<hr />
			<div style="display: none;">
				<form id="nameCheckForm" action="<%=path %>/userNameCheck.action" method="post" >
				<input type="text" name="userName" id="nameCheckName" />
				</form>
			</div>
				
                <form id="srcForm" action="<%=path %>/teamRegister.action" method="post" onsubmit="return checkRegister()">
				<table width="100%" cellspacing="2">
				
					<tr height="30px">
						<td class="form_strong" align="right" valign="middle" style="width: 40%">
							用户名：
						</td>
						<td>
							<table>
								<tr>
									<td>
										<input type="text" name="newteam.username" id="_userName" value="<%=username %>" maxLength=8 onblur="nameCheckNull()" onkeyup="nameCheckNull()"/>
									</td>
									<td>
										<span id="error1" style="text-align:center; color:#FF0000;"></span>
										<a href="Javascript:nameCheck();">检查用户名</a>
										<%if(info != null){%>
										<br />
										<span style="display: inline; color: #F33;"><%=info%></span>
										<%}%>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr height="30px">
						<td class="form_strong" align="right" valign="middle">
							密码：
						</td>
						<td>
							<input type="password" id="newpassword1" maxLength=20 onblur="checkLoginPassword()" onkeyup="checkLoginPassword()"/>
							<span id="error3" style="text-align:center; color:#FF0000;"></span>
						</td>
						<td></td>
					</tr>
					<tr height="30px">
						<td class="form_strong" align="right" valign="middle">
							确认密码：
						</td>
						<td>
							<table>
								<tr>
									<td>
										<input type="password" name="newteam.password" id="newpassword2" onblur="checkPasswordSame()" onkeyup="checkPasswordSame()"/>
											<span id="error2" style="text-align:center; color:#FF0000;"></span>
									</td>
									<td>
										<span id="info" style="display: none; color: #F33;">你输入的新密码不一致</span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td align="center" colspan="2">
							<input type="submit" id="button" value=" 注册 " />
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>